package com.lfg.leetcode.leetcode100;

import com.lfg.leetcode.leetcode0.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class No112maxProfit {

    public static void main(String[] args) {
        int ret = maxProfit(new int[]{1,2,3,4,5});
        System.out.println("[" + ret + "]");
    }

    public static int maxProfit(int[] prices) {
        int[] dp = new int[prices.length+1];
        for(int i=1;i<prices.length;i++){
            dp[i] = Math.max(dp[i-1], dp[i-1]+prices[i]- prices[i-1]);
        }
        return dp[prices.length-1];
    }

}
